package bookticket.crm.user.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import bookticket.crm.recharge.service.RechargeService;
import bookticket.crm.user.dao.UserDao;
import bookticket.crm.user.entity.UserEntity;
import bookticket.crm.user.service.UserService;
import bookticket.crm.vip.dao.VipDao;
import bookticket.crm.vip.entity.VipEntity;


@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao dao;
	
	@Autowired
	private VipDao vipDao;
	
	@Autowired
	private RechargeService rechargeService;
	
	@Override
	public int register(UserEntity entity) {
		
		int counter = dao.register(entity);
		return counter;
	}

	@Override
	public UserEntity findByPhoneAndPassword(UserEntity entity) {
		
		return dao.findByPhoneAndPassword(entity);
	}

	@Override
	public List<UserEntity> findAll(Map<String, Object> pageMap) {
		
		return dao.findAll(pageMap);
	}

	@Override
	public int getTotalCounter() {
		return dao.getTotalCounter();
	}

	@Override
	public int updateByPhone(UserEntity userEntity) {
		return dao.updateByPhone(userEntity);
	}

	@Override
	public UserEntity findByPhone(String phone) {
		return dao.findByPhone(phone);
	}

	@Override
	public int findUserVipId() {
		return dao.findUserVipId();
	}

	

	@Override
	public List<VipEntity> findVipAll() {
		return vipDao.findAllNoPage();
	}

	@Override
	public int findTotalRechargeAmount() {
		return rechargeService.findUserTotalRecharge();
	}
	
}
